package xiu_xiu.view_A_main;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import com.xiu_xiu.R;

import org.xutils.view.annotation.ViewInject;

import xiu_xiu.base.MainActivity;
import xiu_xiu.view_Ab_rescue.RescueGoodPersonFragment;
import xiu_xiu.view_Ab_rescue.RescueMajorFragment;
import xiu_xiu.view_Ac_gold_annoucement.GoldAGoodPersonFragment;
import xiu_xiu.view_Ac_gold_annoucement.GoldAMajorFragment;

/**
 * 金榜
 * Created by 阳 on 2016/4/1.
 */

public class GoldAnnouncementActivity extends MainActivity {

    @ViewInject(R.id.container)
    private ViewPager mViewPager;


    @ViewInject(R.id.tabs)
    private TabLayout tabLayout;

    private SectionsPagerAdapter mSectionsPagerAdapter;


    public static void startUI(Context context) {
        Intent intent = new Intent(context, GoldAnnouncementActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rescue);

        initview();
        bottomNavigation(R.id.bottom_bar_ll3);


    }

    /**
     * 初始化
     */
    private void initview() {
//        setTitleMore(View.INVISIBLE, View.VISIBLE, "营救", null, null, null);

        tabLayout.setScrollBarSize(500);
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
        mViewPager.setAdapter(mSectionsPagerAdapter);
        tabLayout.setupWithViewPager(mViewPager);

    }


    public class SectionsPagerAdapter extends FragmentPagerAdapter {

        public SectionsPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            switch (position) {
                case 0: {
                    return new GoldAMajorFragment();
                }
                case 1: {
                    return new GoldAGoodPersonFragment();
                }


            }
            return null;
        }

        @Override
        public int getCount() {
            return 2;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch (position) {
                case 0:
                    return "专业金榜";
                case 1:
                    return "雷锋金榜";

            }
            return null;
        }
    }


}
